package file;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) throws IOException {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入您要创建的文件名:");//提示用户数出创建的文件名
        String name= scanner.next();
        File file = new File(name);
        while (true) {
            if (file.exists()) {
             scanner.next();
                System.out.println("文件已存在,请重新输入");
            } else {
                file.createNewFile();
                System.out.println("已创建");
                break;

            }
        }
    }
}
